package cn.gson.crm.control.interesting;

import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.InterestingDao;
import cn.gson.crm.model.entity.Interesting;

/**
 * Servlet implementation class InterestingServlet
 */
@WebServlet("/interesting")
public class InterestingServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private InterestingDao indao=new InterestingDao();
       
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {	
		String p = request.getParameter("page");
		String interestingName = request.getParameter("interestingName");
		if (p == null || p.isEmpty()) {
			p = "1";
		}
		Integer page = Integer.parseInt(p);
		// 当前页数据
		List<Interesting> interestingNameList = indao.getPageInterestingListByType(page, interestingName);
		// 总页数
		int totalPage = indao.getTotalPage(interestingName);
		request.setAttribute("queryString", noPageQueryString());
		request.setAttribute("interestingNameList", interestingNameList);
		request.setAttribute("totalPage", totalPage);
		request.setAttribute("page", page);
		forward("interesting/interesting.jsp");}
	
}
